const VUE_APP_API_URL = "https://admin.fortu  najewellery.net/";

// 

// const MODE = 'universal';  //服务器渲染模式 (需要独立部署) 打包命令 npm run build
const MODE = "spa"; //单页面形式渲染模式 (打包后将 dist目录覆盖到 public/pc 目录下) 打包命令: npm run generate

let plugins = []
if (process.env.NODE_ENV === 'production') {
	plugins.push("transform-remove-console")
}



export default {
	env: {
		BASE_URL: VUE_APP_API_URL
	},
	buildDir: 'nuxt-dist',
	// ssr: true,
	mode: MODE,

	head: {
		title: "",
		meta: [
			{ charset: "utf-8" },
			{ name: "viewport", content: "width=device-width, initial-scale=1" },

			{ name: "format-detection", content: "telephone=no" },
			{
				hid: "keywords",
				name: "keywords",
				content: ""
			},
			{
				hid: "description",
				name: "description",
				content: ""
			},
			{
				httpEquiv: "Content-Security-Policy",
				content: "upgrade-insecure-requests"
			}
		],
		link: [{ rel: "icon", type: "image/x-icon", href: "https://dsfw.oss-cn-shanghai.aliyuncs.com/baolian/202309261433970.ico" }],
		script: [
		]
	},
	babel: {
		plugins
	},
	server: {
		// host: '10.55.66.138', // 这里设置为你的 IP 地址，可以使用 'localhost' 或 '127.0.0.1'
		// port: 6666 // 这里设置为你想要的端口号

	},
	loading: {
		color: "#fff"
	},
	css: ["element-ui/lib/theme-chalk/index.css", "~assets/css/index.scss", '@/assets/css/main.css',],

	plugins: [
		{ src: "~plugins/lazyload.js", ssr: false },
		{ src: "~plugins/main.js", ssr: false },
		{ src: "~plugins/v-viewer.js", ssr: false },

		// { src: "~plugins/elLoading.js", ssr: false },
		// "~plugins/main.js",
		"~/plugins/await-to-js.js",


		"~/plugins/router.js",
		"~/plugins/axios",
		"~plugins/element-ui.js",

		{ src: "~/plugins/vue-amap.js", ssr: false },

		{ src: "~plugins/aos.js", ssr: false },

	],

	components: [{ path: "~/components", extensions: ["vue"] }],
	buildModules: ["@nuxtjs/tailwindcss"],




	//this.$cookies.get('cookieName');
	//this.$cookies.set('cookieName' , 'name);

	modules: ["@nuxtjs/axios", "@nuxtjs/auth", "cookie-universal-nuxt"],

	axios: {
		baseURL: VUE_APP_API_URL,
		// proxyHeaders: false,
		// credentials: false,
		// debug: `${process.env.NODE_ENV}` !== "production"
	},

	// proxy: {
	//   '/api': {
	//     target: 'http://amumu.v4.idcfengye.com',
	//     changeOrigin: true,
	//     pathRewrite: {
	//       '^/api': '/',
	//     },
	//   },
	// },
	router: {
		// 切换回到顶部
		scrollBehavior(to, from, savedPosition) {
			return { x: 0, y: 0 };
		}
		// 路由中间件
		// middleware: ["auth"]
	},

	//this.$auth.user
	//this.$auth.loggedIn
	// this.$auth.logout

	// 请求全局自带 token 头，省去写拦截器
	// 自动登录、获取用户信息，省去大片代码
	// 自动鉴权、跳转，省去路由卫士
	// 令牌持久化，刷新页面不丢失，省去大片代码
	// 友好的 api ，人性化存取（官方还提供了操作的 api ，详见官方文档）
	auth: {
		strategies: {
			local: {
				_scheme: "local",
				endpoints: {
					logout: {
						url: "/api/logout",
						method: "post"
					},
					user: {
						url: "/app/user/userInfo",
						method: "get",
						propertyName: false
					}
				}
			},
			local1: {
				_scheme: "local",
				endpoints: {
					login: {
						url: "/app/user/verificationCodeLogin",
						method: "post",
						propertyName: "token"
					},
					logout: {
						url: "/api/logout",
						method: "post"
					},
					user: {
						url: "/app/user/userInfo",
						method: "get",
						propertyName: false
					}
				}
			},
			local2: {
				_scheme: "local",
				endpoints: {
					login: {
						url: "/app/user/pcPwdLogin",
						method: "post",
						propertyName: "token"
					},
					logout: {
						url: "/api/logout",
						method: "post"
					},
					user: {
						url: "/app/user/userInfo",
						method: "get",
						propertyName: false
					}
				}
			}
		},
		redirect: {
			login: "/login",
			logout: "/",
			callback: "/login",
			home: false
		},
		cookie: {
			options: {
				maxAge: 60 * 60 * 24 * 7
			}
		},
		localStorage: false
	},

	build: {
		extractCSS: { allChunks: true },
		// postcss: {
		// 	// plugins: {
		// 	//   'postcss-pxtorem': {
		// 	//     rootValue: 192,
		// 	//     propList: ['*']
		// 	//   }
		// 	// },
		// 	// preset: {
		// 	//   autoprefixer: true
		// 	// }

		// 	plugins: {
		// 		autoprefixer: {
		// 			overrideBrowserslist: [
		// 				"Android 4.1",
		// 				"iOS 7.1",
		// 				"Chrome > 31",
		// 				"ff > 31",
		// 				"ie >= 8",
		// 				"last 10 versions" // 所有主流浏览器最近10版本用
		// 			],
		// 			grid: true
		// 		},
		// 		"postcss-pxtorem": {
		// 			rootValue: 192,
		// 			propList: ["*"]
		// 		}
		// 	}
		// },
		// // 防止重复打包
		vendor: ["axios"]
	},

	devtools: {
		enabled: false
	}
};
